import React, { useState } from 'react'
import Button from './Button';
import Image from './Image';

export default function ImageCom() {
  //定义一个状态   『状态提升』
  let [src, setSrc] = useState('http://api.xiaohigh.com/image/random');
  //声明 change 函数
  let change = () => {
    //更新状态
    setSrc('http://api.xiaohigh.com/image/random?_t='+Date.now());
  }

  return (
    <div>
      <Button change={change} />
      <hr />
      <Image url={src} />
    </div>
  )
}
